# from moviepy.editor import VideoFileClip
#
# # 加载视频文件
# clip = VideoFileClip("E:/video/base.mp4")
#
# # 提取音频
# audio = clip.audio
#
# # 将音频保存为单独的文件
# audio.write_audiofile("E:/video/audio.mp3")

import os
from moviepy.editor import VideoFileClip

# 视频文件夹路径
video_folder = "C:/Users/ReasonDuan/Videos/Captures"

# 遍历视频文件夹
for filename in os.listdir(video_folder):
    if filename.endswith(".mp4"):  # 假设视频文件是mp4格式
        video_path = os.path.join(video_folder, filename)
        audio_path = os.path.join(video_folder, os.path.splitext(filename)[0] + ".mp3")

        # 加载视频文件并提取音频
        clip = VideoFileClip(video_path)
        clip.audio.write_audiofile(audio_path)



